/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-01-08
 * Time: 15:20
 */
public class test2 {
    /*
    LeetCode LCR 089 打家劫舍
     */
    public int rob(int[] nums) {
        int n = nums.length;
        int[] f= new int[n];
        int[] g= new int[n];
        f[0] = nums[0];
        for(int i=1;i<n;i++){
            f[i] = g[i-1]+nums[i];
            g[i] = Math.max(f[i-1],g[i-1]);
        }

        return Math.max(f[n-1],g[n-1]);
    }
}
